package com.xshang;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @BelongsProject: simpleframework
 * @BelongsPackage: com.xshang
 * @Author: xshang
 * @CreateTime: 2023-06-23  14:58
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@WebServlet("/helloServlet")
public class HelloServlet extends HttpServlet {


    @Override
    public void init() {
        System.out.println("init.....初始化servlet");
    }

    @Override
    public void destroy() {
        System.out.println("destroy.....销毁方法");
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("是我service执行了doGet方法......我是入口...");
        doGet(req,resp);
    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = "我的简易版框架!";
        log.debug("name is " + name);
        request.setAttribute("name", name);
        // 指定要转发到的jsp页面
        request.getRequestDispatcher("/WEB-INF/jsp/hello.jsp").forward(request, response);
    }
}
